<?php

require_once dirname(__FILE__) . '/../_data/LzSqlTest.php';

$sql    = new LzTestClass('LzSqlTest');

LzTests::ln(
        $sql->parseCmp('foo =', '= bar'),
        $sql->parseCmp('foo !=', '!= bar'),
        $sql->parseCmp('foo   LIKE', 'bar like'),
        $sql->parseCmp('foo   !LIKE   ', 'not bar like'),
        $sql->parseCmp('foo IN', 'bar'),
        $sql->parseCmp('foo !IN', array('baz', 'biz')),
        $sql->parseCmp('foo BETWEEN', array('a', 'b')),
        $sql->parseCmp('foo !BETWEEN', array(1, 10))
    );

try { $sql->parseCmp('foo BETWEEN', array()); }
catch (LzBadUsage $e) { LzTests::ln('between array() failed'); }

try { $sql->parseCmp('foo BETWEEN', array(1)); }
catch (LzBadUsage $e) { LzTests::ln('between array(1) failed'); }

try { $sql->parseCmp('foo BETWEEN', array(1, 2, 3)); }
catch (LzBadUsage $e) { LzTests::ln('between array(1, 2, 3) failed'); }

try { $sql->parseCmp('foo BETWEEN', 'asd'); }
catch (LzBadUsage $e) { LzTests::ln('between scalar failed'); }

try { $sql->parseCmp('foo BETWEEN', new stdClass); }
catch (LzBadUsage $e) { LzTests::ln('between object failed'); }

var_dump($sql->data());

?>
---EXPECT---
|foo| = :BIND0
|foo| != :BIND1
|foo| LIKE :BIND2
|foo| NOT LIKE :BIND3
|foo| IN (:BIND4)
|foo| NOT IN (:BIND5, :BIND6)
|foo| BETWEEN :BIND7 AND :BIND8
|foo| NOT BETWEEN :BIND9 AND :BIND10
between array() failed
between array(1) failed
between array(1, 2, 3) failed
between scalar failed
between object failed
array(11) {
  ["BIND0"]=>
  string(5) "= bar"
  ["BIND1"]=>
  string(6) "!= bar"
  ["BIND2"]=>
  string(8) "bar like"
  ["BIND3"]=>
  string(12) "not bar like"
  ["BIND4"]=>
  string(3) "bar"
  ["BIND5"]=>
  string(3) "baz"
  ["BIND6"]=>
  string(3) "biz"
  ["BIND7"]=>
  string(1) "a"
  ["BIND8"]=>
  string(1) "b"
  ["BIND9"]=>
  int(1)
  ["BIND10"]=>
  int(10)
}

